#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>

int main()
{
    int n, num, p, i, a, b, l, r;
    int ans[5050];
    scanf("%d", &n);
    for (num = 1; num <= n; num++)
    {
        memset(ans, 0, sizeof(ans));
        scanf("%d %d %d %d", &a, &b, &l, &r);
        p = a;
        a = a % b;
        int k = 0;
        while (k <= r)
        {
            a = a * 7;
            ans[k] = a / b;
            a = a % b;
            k++;
        }
        printf("Problem set %d: %d / %d, base 7 digits %d through %d: ", num, p, b, l, r);
        for (i = l; i <= r; i++)
        {
            printf("%d", ans[i]);
        }
        printf("\n");
    }
    return 0;
}